package win.doyto.service.data.report.support;

import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.View;
import win.doyto.service.data.report.AbstractReportView;
import win.doyto.service.data.report.ReportService;

/**
 * ReportXlsService
 *
 * @author f0rb on 2017-12-20.
 */
@Slf4j
@Service("reportXlsxService")
public class ReportXlsxService extends ReportXlsService {

    @Override
    public String getExtension() {
        return "xlsx";
    }

    @Override
    protected Workbook createWorkbook() {
        return new XSSFWorkbook();
    }

    @Bean
    View xlsView(ReportService reportXlsService) {
        return new AbstractReportView(reportXlsService, "application/vnd.ms-excel");
    }

    @Bean
    View xlsxView(ReportService reportXlsxService) {
        return new AbstractReportView(reportXlsxService, "application/vnd.ms-excel");
    }

}
